package com.skt.exception;

import lombok.Getter;

@Getter
public enum RentalErrorCode implements ErrorCode {

    // ========== 通用租赁错误 (30xxx) ==========
    RENTAL_OPERATION_FAILED(30001, "租赁操作失败"),
    RENTAL_ORDER_NOT_FOUND(30002, "租赁订单不存在"),
    RENTAL_AGREEMENT_NOT_FOUND(30003, "租赁协议不存在"),
    RENTAL_EXTENSION_NOT_FOUND(30004, "续期记录不存在"),
    RENTAL_ACCESS_DENIED(30005, "无权操作该租赁订单"),
    RENTAL_DATA_INVALID(30006, "租赁数据无效"),

    // ========== 费用计算相关 (301xx) ==========
    CALCULATION_FAILED(30101, "费用计算失败"),
    INVALID_RENTAL_DATES(30102, "租赁日期无效"),
    RENTAL_DAYS_TOO_SHORT(30103, "租赁天数过短"),
    RENTAL_DAYS_TOO_LONG(30104, "租赁天数过长"),
    RENTAL_DAYS_INVALID(30105, "租赁天数无效"), // 新增
    START_DATE_BEFORE_TODAY(30106, "租赁开始日期不能早于今天"),
    END_DATE_BEFORE_START(30107, "租赁结束日期不能早于开始日期"),
    DEPOSIT_CALCULATION_FAILED(30108, "押金计算失败"),
    RENTAL_PERIOD_TOO_LONG(30109, "租赁周期过长"), // 新增

    // ========== 结算下单相关 (302xx) ==========
    CHECKOUT_FAILED(30201, "结算下单失败"),
    CART_ITEM_INVALID(30202, "购物车项无效"),
    STOCK_NOT_ENOUGH(30203, "库存不足，无法下单"),
    PRICE_CHANGED(30204, "商品价格已变动，请重新确认"),
    MERCHANT_UNAVAILABLE(30205, "商家暂不可用"),
    ORDER_CREATE_FAILED(30206, "订单创建失败"),
    PAYMENT_INIT_FAILED(30207, "支付初始化失败"),

    // ========== 租赁协议相关 (303xx) ==========
    AGREEMENT_GENERATE_FAILED(30301, "协议生成失败"),
    AGREEMENT_SIGN_FAILED(30302, "协议签署失败"),
    AGREEMENT_ALREADY_SIGNED(30303, "协议已签署"),
    AGREEMENT_EXPIRED(30304, "协议已过期"),
    SIGNATURE_INVALID(30305, "签名无效"),
    AGREEMENT_CONTENT_EMPTY(30306, "协议内容为空"),

    // ========== 租赁续期相关 (304xx) ==========
    EXTENSION_FAILED(30401, "续期失败"),
    EXTENSION_NOT_ALLOWED(30402, "当前状态不允许续期"),
    MAX_EXTENSION_EXCEEDED(30403, "超过最大续期天数"),
    EXTENSION_DATE_INVALID(30404, "续期日期无效"),
    ORIGINAL_ORDER_COMPLETED(30405, "原订单已完成，无法续期"),
    EXTENSION_AMOUNT_INVALID(30406, "续期金额无效"),

    // ========== 支付相关 (305xx) ==========
    PAYMENT_FAILED(30501, "支付失败"),
    PAYMENT_RECORD_NOT_FOUND(30502, "支付记录不存在"),
    PAYMENT_AMOUNT_MISMATCH(30503, "支付金额不匹配"),
    PAYMENT_TIMEOUT(30504, "支付超时"),
    REFUND_FAILED(30505, "退款失败"),
    PAYMENT_STATUS_INVALID(30506, "支付状态无效"),

    // ========== 库存相关 (306xx) ==========
    INVENTORY_LOCK_FAILED(30601, "库存锁定失败"),
    INVENTORY_RELEASE_FAILED(30602, "库存释放失败"),
    CONCURRENT_INVENTORY_UPDATE(30603, "库存并发更新冲突"),
    INVENTORY_INSUFFICIENT(30604, "库存不足"),

    // ========== 订单状态相关 (307xx) ==========
    ORDER_STATUS_INVALID(30701, "订单状态无效"),
    ORDER_CANNOT_MODIFY(30702, "订单不可修改"),
    ORDER_ALREADY_COMPLETED(30703, "订单已完成"),
    ORDER_CANCELLED(30704, "订单已取消"),
    ORDER_EXPIRED(30705, "订单已过期"),

    // ========== 业务规则相关 (308xx) ==========
    BUSINESS_RULE_VIOLATION(30801, "违反业务规则"),
    MAX_RENTAL_ITEMS_EXCEEDED(30802, "超过最大租赁商品数量"),
    TOTAL_AMOUNT_EXCEED_LIMIT(30803, "总金额超过限制"),
    MERCHANT_BLACKLISTED(30805, "商家已被列入黑名单"),

    // ========== 数据验证相关 (309xx) ==========
    INVALID_RENTAL_REQUEST(30901, "租赁请求参数无效"),
    INVALID_CUSTOMER_INFO(30902, "客户信息无效"),
    INVALID_MERCHANT_INFO(30903, "商家信息无效"),
    INVALID_PAYMENT_INFO(30904, "支付信息无效"),
    DATE_VALIDATION_FAILED(30905, "日期验证失败");

    private final int code;
    private final String message;

    RentalErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }
}